<%--
  Created by IntelliJ IDEA.
  User: 12822
  Date: 2023/12/9
  Time: 14:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="Dao.Shop" %>
<%@ page import="Dao.ShopWay" %>
<%@ page import="java.util.ArrayList" %>
<html>
<head>
    <title>购物</title>
    <link href="color.css" rel="stylesheet">
</head>
<body background="pic/buy.png">
<% String name= (String) request.getSession().getAttribute("name");%>
    <div class="buy">
    <form action="buy.do" method="post">
    <table border="1">
    <tr>
        <th>名称</th>
        <th>价格</th>
        <th>数量</th>
        <th>购买数量</th>
    </tr>
    <% ShopWay shopWay = new ShopWay();
        ArrayList<Shop> shopArrayList = shopWay.getAllData();
        for (Shop shop : shopArrayList) {
    %>
    <tr>
        <td><%= shop.getName() %></td>
        <td><%= shop.getPrice() %></td>
        <td><%= shop.getNumber() %></td>
        <td><input type="number" name="buy_number_<%=shop.getId()%>" min="0" max="<%=shop.getNumber()%>" value="0"></td>
    </tr>
    <% } %>
    </table>
    <br>
    <br>
    <input type="submit" onclick="message()" class="btn" style="display:block;margin:0 auto" value="添加">
    </form>
    </div>
<a href="shopcar.jsp" class="BuyAndShow">前往购物车</a>
</body>
</html>
